<template>
  <button @click="sendCond">{{item===0?'发送验证码':`${item}秒`}}</button>
</template>

<script>
import { ref } from 'vue'
import { useIntervalFn } from '@vueuse/shared'
export default {
  setup () {
    const item = ref(0)
    const { resume, pause } = useIntervalFn(() => {
      console.log('定时器')
      item.value--
      if (item.value <= 0) { pause() }
    }, 1000, { immediate: false })
    const sendCond = () => {
      item.value = 60
      resume()
    }
    return { sendCond, item }
  }
}
</script>

<style>

</style>
